﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml.Linq;

namespace PowerPointAddIn3
{
    public class BlogsManager
    {

        private BlogsManager()
        {

        }
        private static BlogsManager m_Instance = new BlogsManager();

        public static BlogsManager BlogsManagerInstance
        {
            get { return m_Instance; }
        }
 
        public void Initialize()
        {
            if (string.IsNullOrEmpty(WorkDir))
            {
                Properties.Settings.Default.WorkDir=Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),"My Blogs");
            }
            if (!Directory.Exists(Properties.Settings.Default.WorkDir))
            {
                Directory.CreateDirectory(Properties.Settings.Default.WorkDir);
            }
            string metadataPath = Path.Combine(Properties.Settings.Default.WorkDir, "Blogs.xml");
            if (!File.Exists(metadataPath))
            {
                XElement blogsMetadata = new XElement("blogs", new XAttribute("defaultBlog", string.Empty));
                blogsMetadata.Save(metadataPath);
            }
            

        }
        public string WorkDir
        {
            get { return Properties.Settings.Default.WorkDir; }
            set {
                if (Properties.Settings.Default.WorkDir != value)
                {
                    MoveWorkDirTo(value);
                    Properties.Settings.Default.WorkDir = value;
                }
            }
        }
        public void MoveWorkDirTo(string dir)
        {

        }
    }
}
